<template>
  <div>
    <div class="tit"><span>2023年实验中心实验状态跟踪记录表</span></div>
    <dv-scroll-board :config="config" class="table" style="height:30vh" />
  </div>
</template>

<script>
// import moment from 'moment'
import { bnrQuery } from '../../api/dataApi'
export default {
  name: '',

  watch: {
    sname(val) {
      this.sname = val
      this.getData()
    },
    dataList(newData) {
      this.config = {
        header: [
          '实验申请订单号',
          '实验申请人',
          '实验项目',
          '样件来源',
          '样件数量',
          '实验设备',
          '实验负责人',
          '实验开始时间',
          '实验完成时间',
        ],
        headerHeight: document.body.clientHeight > 1080 ? 26 : 40,
        data: newData,
        index: false,
        columnWidth: [150, 120, 150, 120, 100, 140, 120, 140, 140],
        align: ['left'],
        headerBGC: ' ',
        // headerBGC: '#06144f',
        // oddRowBGC: '#06144f',
        oddRowBGC: ' ',
        // evenRowBGC: '#15235c',
        evenRowBGC: 'rgba(52,99,171,0.15)',
        waitTime: '5000',
        rowNum: 8,
      }
    },
  },
  data() {
    return {
      config: null,
      dataList: [],
    }
  },

  props: {
    sname: {
      type: String,
      default: '',
    },
  },

  mounted() {
    this.getData()
  },
  methods: {
    getData() {
      const that = this
      const header = {}
      header['report.tableid'] = 'main@d_trial_report'
      header['dvname'] = this.sname
      // header['t_edate'] = moment()
      //   .add(-1, 'days')
      //   .format('YYYY-MM-DD')
      // header['@t_edate'] = 'large_equal'

      const params = {
        '@params': JSON.stringify(header),
        // _condition: JSON.stringify({ t_edate: 'large_equal' }),
        // pageSize: 10000,
        pageIndex: 0,
        sortField: 't_edate',
        sortOrder: 'desc',
      }
      bnrQuery(params)
        .then((res) => {
          this.qThree(res.data)
        })
        .catch(() => {
          that.$message.error('数据请求失败，请联系管理员！')
        })
    },
    qThree(reportData) {
      const _reportData = []
      reportData.forEach((reportItem) => {
        const _m = []
        _m.push(reportItem.apcode)
        _m.push(reportItem.apsname)
        _m.push(reportItem.tproject)
        // _m.push(reportItem.invname)
        _m.push(reportItem.sample_source)
        _m.push(reportItem.sample_num)
        _m.push(reportItem.dvname)
        _m.push(reportItem.pscharger)
        _m.push(reportItem.t_sdate)
        _m.push(reportItem.t_edate)
        _reportData.push(_m)
      })
      this.dataList = _reportData
    },
  },
}
</script>

<style lang="less" scoped>
.tit {
  .px2font(17);
  .px2vh(padding-top, 15);
  letter-spacing: 2px;
  color: #fff;
  text-align: center;
}
.table-list {
  position: relative;
}
.circle {
  width: 1rem;
  height: 1rem;
  border-radius: 20px;
  display: inline-block;
  margin-right: 5px;
}

.table {
  padding: 10px 25px 15px 25px;
  color: #eee;
}
</style>
